﻿/*----------------------------------------------------------------
//文件功能描述：商品对象。
//创建人：赵国伟
//创建时间：2012-03-18 13:49:54
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Shopping.Common;

namespace Shopping.Model
{
    public class GoodsInfo
    {
        /// <summary>
        /// 商品基本信息；
        /// </summary>
        public Goods BaseInfo;

        /// <summary>
        /// 商品售卖规格信息；
        /// </summary>
        public List<GoodsOnSalesInfo> OnSales;

        /// <summary>
        /// 价格规则；
        /// </summary>
        public List<GoodsPriceRules> PriceRules;

        /// <summary>
        /// 该商品的栏目推荐信息；
        /// </summary>
        public List<IDNameObj> GoodsCommends;

        /// <summary>
        /// 商品类别名称；
        /// </summary>
        public string CategoryName;

        /// <summary>
        /// 品牌名称；
        /// </summary>
        public string BrandName;

        /// <summary>
        /// 产地
        /// </summary>
        public string PlaceName;

        /// <summary>
        /// 包装类型；
        /// </summary>
        public string PackUnit;

        /// <summary>
        /// 商品类型；
        /// </summary>
        public string GoodsUnit;

        public string 上下架日期
        {
            get
            {
                if (this.BaseInfo.SaleStatus == GoodsSaleStatus.未上架.ToString())
                    return "--";
                else if (this.BaseInfo.SaleStatus == GoodsSaleStatus.已上架.ToString())
                    return this.BaseInfo.OnSaleDate.Value.ToString("yyyy-MM-dd");
                else if (this.BaseInfo.SaleStatus == GoodsSaleStatus.已下架.ToString())
                    return this.BaseInfo.OffSaleDate.Value.ToString("yyyy-MM-dd");
                return "";
            }
        }

        /// <summary>
        /// 商品主图；
        /// </summary>
        public GoodsPictures MainPicture;


        /// <summary>
        /// 该商品的所有图片；
        /// </summary>
        public List<GoodsPictures> Pictures;


        /// <summary>
        /// 商品组合；
        /// </summary>
        public List<IDNameObj> Packs;

        /// <summary>
        /// 评论数
        /// </summary>
        public int CommentCounts;

        /// <summary>
        /// 商品打分；
        /// </summary>
        public int EvaluateScores;

        /// <summary>
        /// 销量；
        /// </summary>
        public int SaleQuantity;

        /// <summary>
        /// 库存量；
        /// </summary>
        public int Stocks;


        /// <summary>
        /// 商品的销售价格
        /// </summary>
        public decimal SalePrice
        {
            get
            {
                if (this.BaseInfo.IsRush) //是否为抢购价
                    return this.BaseInfo.RushPrice; 
                else
                    return this.BaseInfo.SalePrice;
            }
        }



        public GoodsInfo()
        {
            this.BaseInfo = new Goods();
            this.BaseInfo.CreateDate = DateTime.Now;
            this.BaseInfo.LastModifyDate = DateTime.Now;
        }

       

    }
}
